package com.cloud.code.opreate;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 *
 * java7之后引入的语法糖,优雅的关闭IO流
 */
public class FileOpreateTest {

    public static void main(String[] args)  {
        String inputfileName = "D:\\新建文本文档.txt";
        String outputfileName = "D:\\copy.txt";
        try (

                FileInputStream fileInputStream = new FileInputStream(inputfileName);
                FileOutputStream fileOutputStream = new FileOutputStream(outputfileName);
        ) {
            int content;

            while ((content = fileInputStream.read()) != -1) {
                fileOutputStream.write(content);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
